<?php

namespace App\ApiBackend\Menu;

use App\Domains\MenuDao;
use App\Domains\RoleDao;
use App\Http\Controllers\ApiBaseController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

/**
 *  菜单删除
 */
class Delete extends ApiBaseController
{

  /**
   * 参数检查
   */
  protected function check(): void
  {
    try {
      request()->validate([
        'id' => 'required',
      ]);
    } catch (\Exception $exception) {
      $this->result["code"] = 1;
      $this->result["message"] = "预检: " . $exception->getMessage();
    }
  }

  /**
   * 业务主体
   */
  protected function service(): void
  {
    //删除数据
    try {
      DB::table('admin_menu')->where('id', request('menuId'))->delete();
    } catch (\Exception $exception) {
      $this->result["code"] = 2;
      $this->result["message"] = "删除数据: " . $exception->getMessage();
    }

    return;
  }
}
